package com.Ryan.Controller;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

	@RequestMapping("/test")
	public String test(){
		return "test";
	}
	
	@RequestMapping("/userInfo")
	public Object userInfo(){
		Subject subject = SecurityUtils.getSubject();
		Object principal = subject.getPrincipal();
		boolean isAuthenticated = subject.isAuthenticated();
		System.out.println("验证是否通过:"+isAuthenticated);
		boolean hasRole = subject.hasRole("admin");
		System.out.println("是否拥有admin的角色:"+hasRole);
		return principal;
	}
}
